<%= javascript_include_tag "sharing.js" -%>
<%= javascript_include_tag 'link_adder.js'-%>
<h1>New Survey</h1>
<div class="show_basic">
  <% form_tag({:action => :create}, :multipart => true) do -%>
    <%= error_messages_for :survey -%>
<div class="right" style="width: 50%;">
				<div id="new-survey-step-2">
				<fieldset style="background-color: #FFFFCC;">
					<legend style="font-size:150%;">2: Details for the new Survey</legend>
			        <p style="margin-top: 0.5em;">
			          <b>Title:</b> (Enter the name of the survey here eg HSE 2005)<br/>
			          <%= text_field_tag 'survey[title]','', :style => "width: 100%;" -%>
			        </p>
	        <p style="margin-top: 0.5em;">
	          <b>Description:</b> (Enter a description of the survey here)<br/>
	          <%= text_area_tag 'survey[description]', '', :style => "width: 100%;", :rows => 5 -%>
	        </p>
	        <p style="margin-top: 0.5em;">
	          <b>Year:</b> (Enter the year of the survey here eg 2005)<br/>
	          <%= text_field_tag 'survey[year]', '', :style => "width: 40%;" -%>
	        </p>
	</fieldset>
	</div>
	<div id="new-survey-step-3">
	<fieldset style="background-color: #FFFFCC;">
		<legend style="font-size:150%;">3: Choose who to share with</legend>
		<div class="left" style="margin-right:1em;">
		<%= render :partial => "sharing" %>
		</div>
		<%= render :partial => "sharing_model" %>
	</fieldset>
	      </div>
	</div>
      <div id="new-survey-step-1" class="left" style="width: 45%;">
	<fieldset style="background-color: #FFFFCC;">
		<legend style="font-size:150%;">1: Choose the Survey type</legend>
		<% if SurveyType.all.size >=1 %>
<p>
	<b>Select an existing Survey type</b><br/>
			<%= select_tag 'survey[survey_type]' ,options_from_collection_for_select(@survey_types, 'id', 'shortname')
			 -%>
			</p>

			<p>
			<b style="font-size:larger;">OR</b>
			</p>
			<% else -%>
			<br/>
<b style="font-style: italic; background-color: red;">There are no existing survey types, please enter the details for a new one when loading your new survey.</b><br/><br/>
						<% end %>
						<p>
<b>Create a new Survey type</b><br/>


				<b>Name:</b> (Enter full survey name here eg Health Survey for England)<br/>
			<%= text_field_tag 'survey_type_name', '', :style => "width: 100%;margin-bottom:0.5em;" -%><br/>
			<b>Short Name:</b> (Enter short survey name here eg HSE)<br/>
			<%= text_field_tag 'survey_type_shortname', '', :style => "width: 40%;margin-bottom:0.5em;" -%><br/>
			<b>Description:</b> (Enter a description of the new survey type here)<br/>
			<%= text_area_tag 'survey_type_description', '', :style => "width: 100%;margin-bottom:0.5em;", :rows => 5 -%>
				</p>
				<p>
				<% if current_user.is_admin? %>
				<b>UKDA Survey?</b>
				Yes
				<%= radio_button_tag 'ukda_survey', 'yes', false, :onclick=>"$('world_sharing_div').hide();$('sharing_scope_4').disabled = true;$('sharing_scope_4').selected = false;if (this.checked) { this.checked == false; $('sharing_scope_3').checked = true;};" -%>
				No
				<%= radio_button_tag 'ukda_survey', 'no', true, :onclick=>"$('world_sharing_div').show();$('sharing_scope_4').enable();" -%>
				<% else %>
				<%= hidden_field_tag 'ukda_survey', false -%>
				<% end %>
				</p>
			</fieldset>
			</div>
			<div style="clear:both;">
				</div>

		<div id="specific_sharing"  <%= @sharing_mode == Policy::CUSTOM_PERMISSIONS_ONLY ? hide_style(false) : hide_style(true) -%>>
			<fieldset style="background-color: #FFFFCC;">          
				<legend style="font-size: 150%;">Share with group(s):</legend>
				<div style="clear:both;"></div>
			<%= render :partial => "assets/workgroup_selector", :locals => { :resource_id => "groups", :resource_type => "Groups", :collection=>@groups,:selected=>[],:authorization_for_showing_already_done => false } -%>
		</fieldset>
		</div>
		<div style="clear:both;">
			</div>
      <p style="margin: 2.5em 0 0 0;">
        <%#= render :partial => "assets/sharing_form", :locals => { :groups => @groups, :selected_groups => [] } -%>
      </p>
    <!--</center>-->




    <!-- <p style="margin: 2.5em 0 0 0;"> -->
      <%#= render :partial => "assets/sharing_form" -%>
    <!-- </p> -->

    <!-- <p style="margin: 0;"> -->
      <%#= render :partial => "assets/attribution_form", :locals => { :resource_type => "Survey",  # this is only for presentation, not for any processing
        :existing_attributions => [],
        :attribution_suggestions => Survey.get_all_as_json(current_user) } -%>
    <!-- </p> -->

    <p style="text-align: center; margin-top: 1.5em;">
      <%= submit_tag "Create", :id => "survey_submit_btn", :onclick => "javascript: validateSurveyFields(true); return(false);" -%> or <%= link_to 'Cancel', surveys_path -%>
    </p>
  <% end -%>
</div>
